<% layout('/layouts/default.html', {title: '任务接收', libs: ['dataGrid']}){ %>
<div class="main-content">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-tools pull-left" style="position: relative">
                <ul class="nav nav-tabs bangPing-tabs">
                    <li class="active"><a href="${ctx}/audit/taskReceive/list">${text('待接收')}</a></li>
                    <li ><a href="${ctx}/audit/taskReceive/list1">${text('进行中')}</a></li>
                    <li ><a href="${ctx}/audit/taskReceive/list3">${text('已完成')}</a></li>
                    <li ><a href="${ctx}/audit/taskReceive/list2">${text('已转办')}</a></li>
                </ul>
            </div>
            <#form:form id="searchForm" model="${taskReceive}" action="${ctx}/audit/taskReceive/listData?taskStatus=1&remarks=1" method="post" class="form-inline"
            data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
            <div style="float: right">
                <div class="form-group">
                    <label class="control-label">${text('任务年度')}：</label>
                    <div class="control-inline width-120">
                        <#form:select path="taskYear" items="${yearList}" blankOption="true" data-placeholder="请选择" itemLabel="yearLabel" itemValue="yearValue" class="form-control width-160" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">${text('任务标题')}：</label>
                    <div class="control-inline width-160">
                        <#form:input path="taskTitle" placeholder="请输入任务标题"  maxlength="200" class="form-control width-160"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">${text('任务类型')}：</label>
                    <div class="control-inline width-160">
                        <#form:select path="taskTypeCode" items="${dicts}" blankOption="true" data-placeholder="请选择" itemLabel="dictLabel" itemValue="dictValue" class="form-control width-160"/>
                    </div>
                </div>

                <div class="form-group">
                    <button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
<!--
                    <button type="button" onclick="clickTest()" class="btn btn-primary btn-sm">${text('测试')}</button>
-->
                    <button onclick="cz();" class="btn btn-default btn-sm">${text('重置')}</button>
<!--
                    <button type="button" class="btn btn-primary btn-sm" onclick="exportExcel()">${text('导出')}</button>
-->
                </div>
            </div>
        </#form:form>
    </div>
    <div class="box-body">
        <table id="dataGrid"></table>
        <div id="dataGridPage"></div>
    </div>
</div>
</div>
<% } %>
<script>
    //重置
    function cz(){
        searchForm.reset();
        $('#dataGrid').dataGrid('reloadGrid');
    }

    // 初始化DataGrid对象
    $('#dataGrid').dataGrid({
        searchForm: $("#searchForm"),
        sortableColumn: false, // 列表不允许排序
        // showCheckbox: true,
        columnModel: [
            // {header:'${text("任务年度")}', name:'taskYear', width:80, align:"center"},
            {header:'${text("督办字号")}', name:'messageNumber', index:'a.message_number', width:100, align:"left"},
            {header:'${text("任务标题")}', name:'taskTitle', width:150, align:"left", frozen:true},
            {header:'${text("任务类型")}', name:'taskTypeName', index:'a.task_type_name', width:150, align:"left"},
            {header:'${text("任务内容")}', name:'taskContent', width:150, align:"left", formatter: function(val, obj, row, act){
                    return '<a href="${ctx}/taskdeploy/dcSupTaskInfo/detailForm?id='+row.taskId+'&actionId='+row.id+'" class="btnList" data-title="${text("督办任务信息")}">'+(val||'暂无内容')+'</a>';
                }},
            /*{header:'${text("牵头领导")}', name:'taskLeaderName', index:'a.task_leader_name', width:150, align:"left"},
            {header:'${text("牵头责任单位")}', name:'leaderOrgName', width:150, align:"center"},*/
            // {header:'${text("联系人")}', name:'contactName', width:150, align:"center"},
           /* {header:'${text("接收时间")}', name:'receiveTime', width:150, align:"center"},
            {header:'${text("状态")}', name:'taskStatus', width:80, align:"center", formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('dc_receive_status')}, val, '${text("未知")}', true);
                }},*/
            {header:'${text("操作")}', name:'actions', width:250,align:"center", formatter: function(val, obj, row, act){
                    var actions = [];
                    <% if(hasPermi('audit:taskReceive:edit')){ %>
                        if (row.taskStatus == '1'){
                        actions.push('<a href="${ctx}/audit/taskReceive/receive?taskStatus=2&id=' + row.id + '" class="btn btn-primary btn-xs btnList" title="${text("接收")}" data-confirm="${text("确定接收任务吗？")}"><span>接收</span></a>&emsp;');
                    }else{
                        actions
                            .push('<a href="${ctx}/audit/taskReceive/taskReceiveFive?isNewRecord=true&id=' + row.id + '&taskId=' + row.taskId + '" class="btn btn-primary btn-xs btnList" title="${text("反馈列表")}"><span>反馈列表</span></a>&emsp;');
                        // if(row.explainFlag=='0') {
                        //     actions
                        //         .push('<a style="cursor:pointer;" onclick=clickTwo("' + row.id + '") class="btn btn-primary btn-xs" title="${text("申请批示")}" ><span>申请批示</span></a>&emsp;');
                        // }
                        /*actions
                            .push('<a style="cursor:pointer;" onclick="clickThree()" class="btnList" title="${text("审批记录")}" ><span>审批记录</span></a>&emsp;');*/
                       if(row.isFeedback==0) {
                        actions
                            .push('<a style="cursor:pointer;" onclick=clickFour("'+row.id+'") class="btn btn-primary btn-xs" title="${text("工作安排")}"><span>工作安排</span></a>&emsp;');
                       }
                        /*actions
                            .push('<a  href="${ctx}/audit/taskReceive/taskReceiveFive?isNewRecord=false&id=' + row.id + '&taskId=' + row.taskId + '" class="btn btn-primary btn-xs btnList" title="${text("反馈历史")}"><span>反馈历史</span></a>');*/
                    }
                        <% } %>
                return actions.join('');
            }}
    ],
    // 加载成功后执行事件
    ajaxSuccess: function(data){

    }
    });
    function exportExcel(){
        window.open("${ctx}/audit/taskReceive/exportData");
    }
    function clickTwo(id){
        js.layer.open({
            type: 2,
            title: ['申请批示'],
            area: ['800px', '200px'],
            scrollbar: true,
            shadeClose: false,
            content: "${ctx}/audit/taskReceive/taskReceiveTwo?id="+id,
            btn1: function (index, layero) {
            },
            end:function () {
                $('#dataGrid').dataGrid('refresh', 1, 20);
            }
        });
    }
    function clickFour(id){
        js.layer.open({
            type: 2,
            title: ['工作安排'],
            area: ['800px', '200px'],
            scrollbar: true,
            shadeClose: false,
            content: "${ctx}/audit/taskReceive/taskReceiveFour?id="+id,
            btn1: function (index, layero) {
            },
            end:function () {
                $('#dataGrid').dataGrid('refresh', 1, 20);
            }
        });
    }
    function clickTest(){
        // $.ajax({
        //     type: 'get',
        //     url: "${ctx}/feedback/dcSupTaskFeedback/isFirstOrLast?actionId=1506508034207813632",
        // });
        $.ajax({
            type: 'get',
            url: "${ctx}/action/dcSupTaskAction/scheduledActionEveryday",
        });
    }
</script>